<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" session="false" %>
<%@ page import="com.atozsoft.commonutil.Constants"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ page import="commonj.sdo.DataObject"%>
<%@page import="com.eos.data.datacontext.UserObject"%>	
	
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- 
  - Author(s): houfy
  - Date: 2014-10-31 14:12:31
  - Description:
-->
<head>
	<%@include file="/common.jsp"%>
	<%@include file="/common/common.jsp"%>
    <%@include file="/coframe/tools/skins/common.jsp"%>
	<title>统一待办</title>
	<%
       UserObject userObject = (UserObject)request.getSession().getAttribute("userObject");
		DataObject capUser = (DataObject)userObject.get("capUser");
		// 登陆者所属BU
		String operatorId = capUser.getString("operatorId");
		String userId = userObject.getUserId();
     %>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
</head>
<body>
	<fieldset style="height:99%">
	    <legend><strong>待办</strong></legend>
		<div class="nui-fit">
			<div id="tabs1" class="nui-tabs" activeIndex="0" style="width:100%;height:100%;" plain="true">
			      <div name="dbtab" title="我的待办" style="width:100%;height:100%;">
				        <div class="nui-fit"> 
				        <div id="datagrid1" class="nui-datagrid" style="width:100%;height:100%;" 
				       		 url="com.atozsoft.wf.processOperate.queryMyProcessList.biz.ext"  dataField="processList" sortMode="client" pageSize="20" multiSelect="false">
							    <div property="columns">
					                <div field="PROCESSINSTNAME" width="300px" headerAlign="center" allowSort="true" allowSort="false" renderer="Itemclick">摘要</div>
					                <div field="EMPNAME" width="80px" headerAlign="center" align="center" allowSort="false"  >发起人</div>
					                <div field="CREATEDATE_TO" width="80px" headerAlign="center" align="center" allowSort="false" dateFormat="yyyy-MM-dd HH:mm:ss">发起时间</div>
							    </div>
						</div>
					 </div>    
				</div>  
				<div name="ybtab" title="已完成的待办" style="width:100%;height:100%;"  >
			        <div class="mini-fit"> 
			           <div id="datagrid2" class="nui-datagrid" style="width:100%;height:100%;" 
			       		 url="com.atozsoft.wf.processOperate.queryMyProcessList.biz.ext"  dataField="processList" sortMode="client"
			       		    pageSize="20"   multiSelect="false">
						    <div property="columns">
						        <div type="indexcolumn" align="center" headerAlign="center"></div>
				                <div field="PROCESSINSTNAME" width="250px" headerAlign="center"  allowSort="false" renderer="Itemclickread">摘要</div>
				                <div field="WORKITEMNAME" width="80px" headerAlign="center"   allowSort="false">节点名称</div>
				                <div field="PARTINAME" width="80px" headerAlign="center" allowSort="false" align="center" >操作人</div>
				                <div field="STARTTIME_TO" width="100px" headerAlign="center"  allowSort="false" align="center"  dateFormat="yyyy-MM-dd HH:mm:ss">操作时间</div>
				                <div field="EMPNAME" width="80px" headerAlign="center" align="center" >发起人</div>
				                <div field="CREATEDATE_TO" width="100px" headerAlign="center" allowSort="false" align="center" dateFormat="yyyy-MM-dd HH:mm:ss">发起时间</div>
						    </div>
						</div>
					</div>    
				</div>  
			</div> 
		</div>
	</fieldset>
	<script type="text/javascript">
	    nui.parse();
	    
	    var grid = nui.get("datagrid1");
	    var dataN = {currentstate:0};
	    grid.load({map:dataN});
	    
    	var index=1;
    	var tabs = nui.get("tabs1");
		
		tabs.on("activechanged", function (e) {
        	//nui.alert(e.tab.name);
        	switch(e.tab.name){
        		case "dbtab":
	            	var grid = nui.get("datagrid1");
				    var dataN = {currentstate:0};
				    grid.load({map:dataN});
	            	break;
	            case "ybtab":
	            	var grid2 = nui.get("datagrid2");
				    var dataY = {currentstate:1};
				    grid2.load({map:dataY});
	            	break;
	            default:
        	}
        });
    	
	    var grid2 = nui.get("datagrid2");
	    var dataY = {currentstate:1};
	    grid2.load({map:dataY});

	    // 项目名称链接
		function Itemclick(e){
	            var grid = e.sender;
	            var record = e.record;
	            var workitemid = record.WORKITEMID;
	            var processInstId = record.PROCESSINSTID; 
	            var executeType = record.EXECUTETYPE; //用来标识是否为转发或者抄送
	            var castatus = record.CASTATUS;  //用来标识是否为加审
	            var dataType = ""; //判断数据类型是转发、加审
	            if("1" == executeType) {
	              dataType = "forward-" + record.TRANSMITID +"-"+ record.PCTCREATER; //数据是转发
	            }else if(castatus == '1'){   
	              dataType = "operate-" + record.ADDAPPROVEID +"-"+ record.CACREATER; //数据是加审  
	            }else if(castatus != null && castatus !='1' ){   
	              dataType = "addApprove-" + record.ADDAPPROVEID +"-"+ record.CACREATER; //数据是加审  
	            }else{
	              dataType = record.AGENTFROM?record.AGENTFROM:"<%=userId %>"; //委托人
	            }
	            //页面操作按钮加载(加载状态分：webType  阅读：read；操作：operate；已完成：done)
	            var url = "<%=request.getContextPath()%>/wf/processOperate/process_Detail.jsp?webType=operate&workitemid=" + workitemid +"&processInstId=" + processInstId+"&dataType=" + dataType;
				var name = record.PROCESSINSTNAME;
				var showName = record.PROCESSCHNAME;
	            /* if(url.indexOf("?") > 0)
	              url += "&workitemId=" + workitemId +"&processinstId=" + processinstId;
	            else 
	               url += "?workitemId=" + workitemId +"&processinstId=" + processinstId; */
	           
	            var s = '<a class="New_Button"  style="color:#00C" href="javascript:addtab(\''+url+'\',\''+showName+'\')">'+name+'</a>';                       
	            return s;
		}
		
		// 项目名称链接
		function Itemclickread(e){
	            var grid = e.sender;
	            var record = e.record;
	            var workitemid = record.WORKITEMID;
	            var processInstId = record.PROCESSINSTID; 
	            var executeType = record.EXECUTETYPE; //用来标识是否为转发或者抄送
	            var castatus = record.CASTATUS;  //用来标识是否为加审
	            var dataType = ""; //判断数据类型是转发、加审
	            if("1" == executeType) {
	              dataType = "forward-" + record.TRANSMITID +"-"+ record.PCTCREATER; //数据是转发
	            }else if(castatus != null){   
	              dataType = "addApprove-" + record.ADDAPPROVEID +"-"+ record.CACREATER; //数据是加审  
	            }
	            //页面操作按钮加载(加载状态分：webType  阅读：read；操作：operate；已完成：done)
	            var url = "<%=request.getContextPath()%>/wf/processOperate/process_Detail.jsp?webType=done&workitemid=" + workitemid +"&processInstId=" + processInstId+"&dataType=" + dataType;
				var name = record.PROCESSINSTNAME;
				var showName = record.PROCESSCHNAME;
	            /* if(url.indexOf("?") > 0)
	              url += "&workitemId=" + workitemId +"&processinstId=" + processinstId;
	            else 
	               url += "?workitemId=" + workitemId +"&processinstId=" + processinstId; */
	            var s = '<a class="New_Button"  style="color:#00C" href="javascript:addtab(\''+url+'\',\''+showName+'\')">'+name+'</a>';                       
	            return s;
		}
		
		// 跳转,新增tab页
		function addtab(url,name) {
			window.parent.parent.addtabs(url, "流程审批", "myProcess");
		}  
    </script>
</body>
</html>